package com.zhuanzhuan.hero.user.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import com.zhuanzhuan.hero.user.consts.NumConsts;
import com.zhuanzhuan.hero.user.helper.ZzLockHelper;
import com.zhuanzhuan.hero.user.service.HeroUserAuthenticationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ClassName BmWarehouseAuthJob
 * @Description
 * @Author hanjunjun
 * @Date 2024/6/28 14:38
 */
@Component
@Slf4j
public class BmWarehouseAuthJob {

    @Resource
    private ZzLockHelper lockHelper;

    @Resource
    private HeroUserAuthenticationService userAuthService;

    @XxlJob("modifyBmWarehouseAuthState")
    public ReturnT<String> modifyBmWarehouseAuthState(String param) {
        log.info("modifyBmWarehouseAuthState start param={}", param);
        int batchSize = StringUtils.isBlank(param) ? NumConsts.HUNDRED : Integer.valueOf(param);
        try {
            userAuthService.timedModifyBmWarehouseAuthState(batchSize);
        } catch (Exception e) {
            log.error("modifyBmWarehouseAuthState失败", e);
            XxlJobLogger.log("modifyBmWarehouseAuthState执行异常");
            return ReturnT.FAIL;
        }

        return ReturnT.SUCCESS;
    }
}
